package com.sc.server.system.conf.controller;

import com.sc.server.system.auth.entity.Menu;
import com.sc.server.system.auth.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("rabbitMq")
@Api(description = "mq")
public class RabbitMqController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Autowired
    private IMenuService menuService;
    @GetMapping("fanutTest")
    @ApiOperation("发布消息")
    public void fanutTest(){
        List<Menu> menus = menuService.selectList(null);
        for (Menu menu : menus) {
            rabbitTemplate.convertAndSend("fanout.B",menu);
        }

    }
}
